#include "AI_Commands.h"
using namespace BWAPI;

namespace ai
{
void mineNearestMineral(Unit* unit)
{
        Unit* closestMineral=NULL;
        for(std::set<Unit*>::iterator m=Broodwar->getMinerals().begin();m!=Broodwar->getMinerals().end();m++)
        {
                if (closestMineral==NULL || unit->getDistance(*m)<unit->getDistance(closestMineral))
                        closestMineral=*m;
        }
        if (closestMineral!=NULL)
                unit->rightClick(closestMineral);
}
}